var PrefabLoader = require('PrefabLoader');
var NetSocket = require('NetSocket');
var Observer = require("Observer");

cc.Class({
    extends: Observer,

    properties: {
        addNode: {default: null, displayName: "添加节点", type: cc.Node},

        exitRoomPrefab: {default: null, displayName: "解散房间界面", type: cc.Prefab},

    },

    onLoad: function () {
        this._initMsg();
    },
    _onMsg(msg, data){
        if (msg == GameLocalMsg.GameScene.OnExitRoom) {

            this.addNode.destroyAllChildren();

            var node = cc.instantiate(this.exitRoomPrefab);
            this.addNode.addChild(node);
        } else if (msg == MJNetMsg.recv.DelRoom.msg) {
            PrefabLoader.addLoadingLayer(this.addNode);
            cc.director.loadScene("Center");
        }
    },
    _getMsgList(){
        return [
            GameLocalMsg.GameScene.OnExitRoom,
            MJNetMsg.recv.DelRoom.msg,
            MJNetMsg.recv.ExitRoom.msg,
        ];
    },
    onClickBeganGame(){
        NetSocket.send(MJNetMsg.send.GameJoinRoom, null);

    }

});
